/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package auditenergetic;
import org.xml.sax.*;
import org.xml.sax.ext.DefaultHandler2;

public class Calcul_AporturiCaldura extends DefaultHandler2 {

    public boolean T_ih = false;
    public boolean T_iu = false;
    public boolean b = false;
    public boolean t = false;

    public static String Tih;
    public static String Tiu;
    public static String be;
    public static String tt;

    @Override
    public void startElement(String nsURI, String strippedName,String tagName, Attributes attributes)
        throws SAXException
    {
        if(tagName.equalsIgnoreCase("Aporturi_surse_interioare"))
            T_ih = true;
        if(tagName.equalsIgnoreCase("Aporturi_interioare_încăperilor_neîncălzite_alăturate"))
            T_iu = true;
        if(tagName.equalsIgnoreCase("coeficient_de_reducere"))
            b = true;
        if(tagName.equalsIgnoreCase("numar_de_ore"))
            t = true;
    }
    @Override
    public void characters(char[] ch, int start ,int length)
        throws SAXException
    {
        if(T_ih)
        {
            Tih = new String(ch, start, length);
        }
        T_ih = false;
        if(T_iu)
            Tiu = new String(ch, start, length);
        T_iu = false;
        if(b)
            be = new String(ch, start, length);
        b = false;
        if(t)
            tt = new String(ch, start, length);
        t = false;

    }

    public static double ComputeQs()
    {
        double s, t1 = 0;
        double[] as = new double[3];
        double[] is = new double[3];
        for(int i =0;i<3;i++)
        {
            s = 0;
            for(int j=0;j<3;j++)
            {
        	as[j] = j;
                s += as[j];
            }
            is[i] = i;
            t1 = is[i] * s;
        }
        return t1;
    }
    public static double ComputeQi()
    {
        return (Double.parseDouble(Tih) + (1 - Double.parseDouble(be)) *
                Double.parseDouble(Tiu)) * Double.parseDouble(tt);
    }
    public static double Compute()
    {
        return ComputeQs() + ComputeQi();
    }

}
